<template>
  <!-- 人员类型新增 -->
  <div>
    <i class="el-icon-setting" @click="handleAdd" />
    <el-dialog :modal="false" :title="dialogTitle" :close-on-click-modal="false" class="dialogStyleSmall" :visible.sync="dialogVisible">
      <el-form ref="form" :model="formData" label-width="80px" :rules="rules">
        <el-form-item label="界定范围" prop="cityRange">
          <el-select v-model="formData.cityRange" placeholder="请选择界定范围">
            <el-option
              v-for="item in options"
              :key="item.value"
              size="medium"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="开启规则">
          <el-switch v-model="formData.isStart" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="medium" @click="cancel">取 消</el-button>
        <el-button size="medium" type="primary" @click="submitForm">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// import {
//   detailPersonSupperType} from '@/api/superviseBaseInfo/typeManage/personnelType'
export default {
  name: 'DefinitionRules',
  data() {
    return {
      // 界定范围
      options: [
        {
          value: '0',
          label: '省级'
        },
        {
          value: '1',
          label: '市级'
        },
        {
          value: '2',
          label: '区/县级'
        }
      ],
      /* 新增 start */
      btnDisabled: false,
      dialogTitle: '', // 对话框是否弹出显示
      dialogVisible: false, // 对话框是否弹出显示
      formData: {
        id: '',
        cityRange: '', // 界定范围
        isStart: false
      },
      // from表单校验
      rules: {
        cityRange: [{ required: true, message: '界定范围不能为空', trigger: 'blur' }]
      }
      /* 新增 end */
    }
  },
  methods: {
    handleAdd() {
      this.dialogVisible = true
      this.dialogTitle = '设置外地企业界定规则'
      // 重置表单
    },
    // 弹框取消按钮
    cancel() {
      this.dialogVisible = false
      this.btnDisabled = false
    },
    // 保存
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.dialogVisible = false
        }
      })
    },
    // 清空弹出
    emptyForm() {
      this.resetForm('form')
      this.formData.id = ''
    }
  }
}
</script>

